
//
//  LineTextField.m
//  BLDForPad
//
//  Created by 8b410-2 on 16/11/13.
//  Copyright © 2016年 8b410-2. All rights reserved.
//

#import "LineTextField.h"

@implementation LineTextField

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        UIView *line = [[UIView alloc] init];
        [self addSubview:line];
        [line setBackgroundColor:[UIColor grayColor]];
        
        line.translatesAutoresizingMaskIntoConstraints = NO;
        NSMutableArray *cons = [[NSMutableArray alloc] init];
        NSDictionary *viewDict = @{@"line" : line};
        [cons addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[line(1)]-1-|" options:0 metrics:nil views:viewDict]];
        [cons addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[line]-|" options:0 metrics:nil views:viewDict]];
        [self addConstraints:cons];
    }
    return self;
}

- (instancetype)initWithPlaceholder:(NSString *)placeholder FontSize:(CGFloat)fontsize {
    self = [self initWithFrame:CGRectZero];
    if (self) {
        self.font = [UIFont systemFontOfSize:fontsize];
        self.placeholder = placeholder;
    }
    return self;
}
+ (LineTextField *)lineTextFieldWithPlaceholder:(NSString *)placeholder FontSize:(CGFloat)fontsize {
    return [[LineTextField alloc] initWithPlaceholder:placeholder FontSize:fontsize];
}
@end
